package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.vo.SupplierGoodsVo;
import com.atguigu.jxc.service.PurchaseListGoodsService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/purchaseListGoods")
public class PurchaseListGoodsController {
    @Autowired
    private PurchaseListGoodsService goodsService;

    /**
     * 修改订单状态
     * @param purchaseListId 购买清单列表id
     * @return
     */
    @PostMapping("/updateState")
    public ServiceVO updateState(@RequestParam("purchaseListId") Integer purchaseListId){
        goodsService.updateState(purchaseListId);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS,null);
    }


    /**
     * 进货统计（可根据 商品类别、商品编码或名称 条件查询）
     * @param sTime 起始时间
     * @param eTime 结束时间
     * @param goodsTypeId 商品类型id
     * @param codeOrName 商品编码/名称
     * @return
     */
    @PostMapping("/count")
    public String count(String sTime, String eTime, Integer goodsTypeId, String codeOrName){

        List<SupplierGoodsVo> supplierGoodsVos = goodsService.count(sTime,eTime,goodsTypeId,codeOrName);

        Gson gson = new Gson();
        return gson.toJson(supplierGoodsVos);
    }




}
